package com.ict.event;

import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author wujinpeng
 * @version 1.0
 * @date 2025/2/12 20:04
 * @description
 */
@Component
public class MyEventListener {

    @EventListener
    public void handleMyCustomEvent(MyCustomEvent event) {
        System.out.println("Received message: " + event.getMessage());
    }

    public static void main(String[] args) {

        Map<Integer, String> map = new HashMap<>();

        Integer i = 500;

        map.put(i, "500");

        i = 700;
        System.out.println(Math.sqrt(9));
        map.put(i, "700");


        System.out.println(map.keySet());
        System.out.println(map.values());

        ExecutorService executor = Executors.newFixedThreadPool(3);

        CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "Hello", executor)
                .thenApplyAsync(result -> result + " World!", executor);

        System.out.println(future.join());

        executor.shutdown();
    }
}
